<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<?php 
	include_once('../DAO/DonHangDTO.php');
	include_once('../DAO/DonHangDAO.php');
	
	?>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>Thông tin shop</title>
		<link rel="stylesheet" href="../css/reset.css" type="text/css" />
		<link rel="stylesheet" href="../css/common.css" type="text/css" />
		<link rel="stylesheet" href="../css/seller.css" type="text/css" />
		<script src="../scripts/jquery-1.5.2.min.js"></script>
		<script src="../scripts/common.js"></script>
		<script type="text/javascript" language="javascript">
			var xmlhttp;
			function GetXmlHttpObject()
			{
				if (window.XMLHttpRequest)
				{
					// code for IE7+, Firefox, Chrome, Opera, Safari
					return new XMLHttpRequest();
				}
				if (window.ActiveXObject)
				{
					// code for IE6, IE5
					return new ActiveXObject("Microsoft.XMLHTTP");
				}
				return null;
			} 
			function Huy(id)
			{
				xmlhttp=GetXmlHttpObject();
				xmlhttp.onreadystatechange=Reload;
				var serverUrl="../DAO/DanhSachDonHangDAO.php?id="+id;
				xmlhttp.open("get",serverUrl,true);
				xmlhttp.send(null);
				//alert("1");
			}
			
			function CapNhat(id)
			{
				xmlhttp=GetXmlHttpObject();
				xmlhttp.onreadystatechange=update;
				var serverUrl="../DAO/CapNhatDonHangDAO.php?id="+id;
				xmlhttp.open("get",serverUrl,true);
				xmlhttp.send(null);
				//alert("1");
			}
			
			function Reload()
			{
				if(xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				//alert("2");
					var div=document.getElementById("tbody");
					div.innerHTML=xmlhttp.responseText;
				}
			}
			function update()
			{
				if(xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				//alert("2");
					var div=document.getElementById("tbody");
					div.innerHTML=xmlhttp.responseText;
				}
			}
		</script>
	</head>
	<body>
		<div id="page">
			<?php
				require("../DAO/DataHelper.php");
				require("../webconfig.php");
				include_once("../UserControl/header.php");
			?>

			<div id="content">
				<div id="shop-banner">
					<img src="../temp/shop-banner.jpg" />
				</div>
				<?php
					require("../UserControl_NguoiBan/MenuDanhMucChucNang.php");
				?>
				<div id="seller-shop-info" class="block layout-2col-col2">
					<div class="title">
					  <h3>Quản lí đơn đặt hàng </h3>
				  </div>
					<div class="content" id="content">

						<table style="width: 666px;" id="gradient-style" summary="Meeting Results">

                            <thead>
                                <tr>
                                <th style="text-align: center" scope="col">Mã đơn hàng </th>
								<th style="text-align: center" scope="col">Tên Khách Hàng </th>
                                <th style="text-align: center" scope="col">Ngày đặt </th>
                                <th style="text-align: center" scope="col">Ngày giao </th>
                                <th style="text-align: center" scope="col">Tổng tiền </th>
								<th style="text-align: center" scope="col">Tình trạng </th>
								<th style="text-align: center" scope="col"></th>
								<th style="text-align: center" scope="col"></th>
								<th style="text-align: center" scope="col"></th>
                                </tr>
                            </thead>          
 
                            <tbody id="tbody">
							
							<?php
$result = DonHangDAO::DanhSachDonHang();
for($i = 0 ; $i < count($result) ; $i++)
{
	$row = $result[$i];
?>
                                <tr>
                                <td style="background: #d1d1d1;"><?php echo $row->dh_ma?></td>
								<td style="background: #d1d1d1;"><?php echo $row->dh_username?></td>
								<td style="background: #d1d1d1;"><?php echo $row->dh_ngay_dat?></td>
                                <td style="background: #d1d1d1;"><?php echo $row->dh_ngay_giao?></td>
                                <td style="background: #d1d1d1;"><?php echo $row->dh_tong_tien?></td>
                                <td style="background: #d1d1d1;"><?php
								if($row->dh_tinh_trang ==0)
								{
									echo 'Ðang chờ duyệt';
								}
								if($row->dh_tinh_trang ==1)
								{
									echo 'Ðã duyệt';
								}
								?></td>
								
								<td style="background: #d1d1d1;"><input type="button" value="Hủy" onClick='Huy(<?php echo $row->dh_ma?>);' /></td>
								<td style="background: #d1d1d1;"><input type="button" value="Cập nhật" onClick='CapNhat(<?php echo $row->dh_ma?>);' /></td>
								<td style="background: #d1d1d1;"><a  href="ChiTietDonHang.php?id=<?php echo $row->dh_ma?>&Ten=<?php echo $row->dh_username?>">Xem chi tiết</a></td>
                                </tr>
<?php
		}
?>
							
																

                            </tbody>
                      </table> 
 						
					</div>
				</div>
			</div>
			<?php
				require("../UserControl/footer.php");
			?>
		</div>
	</body>
</html>